package com.asyf.demo.service.impl;

import com.asyf.demo.entity.User;
import com.asyf.demo.mapper.UserMapper;
import com.asyf.demo.service.DemoService;
import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Random;
import java.util.UUID;

/**
 * @Author yjz
 * @Date 2022/10/28 13:34
 */
@Service
@Slf4j
public class DemoServiceImpl implements DemoService {


    @Resource
    private UserMapper userMapper;

    //    @DS("master")
    @DS("slave2")//这个事务切换是没有效果的，因为事务已经开启，数据源就确定
    public void save(Integer num) {
        User user = new User();
        user.setId(2L);
        user.setName("用户名");
        userMapper.insert(user);
//        log.info(String.valueOf(2 / num));
    }
}
